package com.ruoyi.wash.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.wash.domain.ThirdSystem;
import com.ruoyi.wash.mapper.ThirdSystemMapper;
import com.ruoyi.wash.service.IThirdSystemService;
import com.ruoyi.wash.vo.ThirdSystemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 第三方系统信息Service业务层处理
 *
 * @author YanMing.Wang
 * @date 2024-04-20
 */
@Service
public class ThirdSystemServiceImpl implements IThirdSystemService {

    @Autowired(required = false)
    private ThirdSystemMapper thirdSystemMapper;

    /**
     * 查询第三方系统信息
     *
     * @param thirdId 第三方系统信息主键
     * @return 第三方系统信息
     */
    @Override
    public ThirdSystemVO selectThirdSystemById(Long thirdId) {
        return thirdSystemMapper.selectThirdSystemById(thirdId);
    }

    /**
     * 查询第三方系统信息列表
     *
     * @param thirdSystem 第三方系统信息
     * @return 第三方系统信息
     */
    @Override
    public List<ThirdSystemVO> selectThirdSystemList(ThirdSystem thirdSystem) {
        return thirdSystemMapper.selectThirdSystemList(thirdSystem);
    }

    /**
     * 新增第三方系统信息
     *
     * @param thirdSystem 第三方系统信息
     * @return 结果
     */
    @Override
    public int insertThirdSystem(ThirdSystem thirdSystem, String loginName) {
        thirdSystem.setStatus("0");
        thirdSystem.setDelFlag("0");
        // String loginName = ShiroUtils.getLoginName();
        thirdSystem.setCreateBy(loginName);
        thirdSystem.setCreateTime(DateUtils.getNowDate());
        return thirdSystemMapper.insertThirdSystem(thirdSystem);
    }

    /**
     * 修改第三方系统信息
     *
     * @param thirdSystem 第三方系统信息
     * @return 结果
     */
    @Override
    public int updateThirdSystem(ThirdSystem thirdSystem, String loginName) {
        // String loginName = ShiroUtils.getLoginName();
        thirdSystem.setUpdateBy(loginName);
        thirdSystem.setUpdateTime(DateUtils.getNowDate());
        return thirdSystemMapper.updateThirdSystem(thirdSystem);
    }

    /**
     * 批量删除第三方系统信息
     *
     * @param thirdIds 需要删除的第三方系统信息主键
     * @return 结果
     */
    @Override
    public int deleteThirdSystemByIds(String thirdIds) {
        return thirdSystemMapper.deleteThirdSystemByIds(Convert.toStrArray(thirdIds));
    }

    /**
     * 删除第三方系统信息信息
     *
     * @param thirdId 第三方系统信息主键
     * @return 结果
     */
    @Override
    public int deleteThirdSystemById(Long thirdId) {
        return thirdSystemMapper.deleteThirdSystemById(thirdId);
    }

    @Override
    public Integer countByCode(ThirdSystem thirdSystem) {
        return thirdSystemMapper.countByCode(thirdSystem);
    }

    @Override
    public Integer countByName(ThirdSystem thirdSystem) {
        return thirdSystemMapper.countByName(thirdSystem);
    }
}
